import axios from 'axios';
import {useRouter} from 'vue-router';
const service = axios.create({
    baseURL:"/api",
    timeout:5000,
})
service.interceptors.request.use(
    config => {
        return config;
    },
    (error)=>{
        Promise.reject(error);
    }
)
service.interceptors.response.use(
    (response) => {
        return response;
    },
    (error)=>{
        const router = useRouter();
        router.push('/error');
        return Promise.resolve(error.response);
    }
)
export default service;